package com.geek.water.config;

import com.geek.water.service.GlobalWaterPriceTierService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * 全局阶梯水费配置初始化器
 * 在应用启动时自动初始化默认的全局阶梯水费配置
 * @author yangwenqi
 * @date 2025/8/7
 */
@Slf4j
@Component
public class GlobalWaterPriceTierInitializer implements CommandLineRunner {

    @Autowired
    private GlobalWaterPriceTierService globalWaterPriceTierService;

    @Override
    public void run(String... args) throws Exception {
        try {
            log.info("开始初始化全局阶梯水费配置...");
            globalWaterPriceTierService.initializeDefaultTiers();
            log.info("全局阶梯水费配置初始化完成");
        } catch (Exception e) {
            log.error("全局阶梯水费配置初始化失败", e);
        }
    }
}